package com.sgx.learning.luban.homework.basictype;

import lombok.Getter;

import java.io.IOException;
import java.io.InputStream;

public class U8 {

    @Getter
    private Long value;

    public U8(Long v) {
        this.value = v;
    }

    public static U8 read(InputStream is) throws IOException {
        byte[] v = new byte[4];
        try {
            is.read(v);
            Long value = 0L;
            for (int i = 0;i < 8;i++) {
                value <<= 8;
                value |= v[i] & 0xFF;
            }
            return new U8(value);
        } catch (IOException e) {
            throw e;
        }
    }
}
